package com.xja.service.impl;/**
 * @className: AdminServiceImpl
 * @description: TODO 类描述
 * @author: wkx
 * @date: 2022/4/7
 **/

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xja.mapper.AdminMapper;
import com.xja.pojo.Admin;
import com.xja.service.AdminService;
import org.apache.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @ClassName : BlogServiceImpl  //类名

 * @Author : Lenovo //作者
 * @Date: 2022/4/17  10:50
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    private Logger logger = LoggerFactory.getLogger(com.xja.service.impl.AdminServiceImpl.class);
    @Transactional(readOnly = true)
    @Override
    public Admin login(String username) {

        return adminMapper.selectByaName(username);
    }
    @Transactional(readOnly = true)
    @Override
    public List<Admin> getAdminList(Integer page) {
        PageHelper.startPage(page,5);
        List<Admin> admins = adminMapper.selectAdmin();
        PageInfo<Admin> pageInfo = new PageInfo<>(admins);
        pageInfo.setPageNum(page);
        return pageInfo.getList();
    }
    @Transactional(readOnly = true)
    @Override
    public Admin getAdminById(Integer aid) {
        return adminMapper.selectByAid(aid);
    }

}
